package com.dz.tool.Utils;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class ConnectionUtils {

    /**
     * 运行sql脚本
     *
     * @param sqlFilePath 执行的脚本文件
     */
    public void sqlConnection(String sql,String SlaveUrl,String SlaveUsername,String SlavePassword) throws SQLException {
        // 建立连接
        Connection conn = DriverManager.getConnection(SlaveUrl, SlaveUsername, SlavePassword);
        Statement statement = conn.createStatement();
        statement.execute(sql);

        // 关闭连接
        statement.close();
        conn.close();
    }

}
